const state = {
	searchInfo:{}, //初始化时页面数据
	searchTipsList:[], //搜索实时推荐列表
	goodsInfo:[],// 确认搜索后请求回来的数据
}
const mutations = {
	SET_SEARCH_INFO(state,searchInfo){
		state.searchInfo=searchInfo
	},
	SET_SEARCH_TIPS_LIST(state,searchTipsList){
		state.searchTipsList=searchTipsList
    console.log('---', state.searchTipsList)
	},
	REMOVE_SEARCH_TIPS_LIST(state){
		state.searchTipsList=[]
	},
	SET_SEARCH_GOODS_INFO(state,goodsInfo){
		state.goodsInfo=goodsInfo
	},
	REMOVE_SEARCH_GOODS_INFO(state){
		state.goodsInfo=[]
	},
}
const actions = {
	// 获取搜索页面初始数据
	async getSearchInfo({commit}){
		const result = await this.$API.search.getSearchInfo()
		if (result.code ==='200'){
			commit('SET_SEARCH_INFO',result.data)
		}
	},
	// 获取搜索时实时获取搜索提示列表
	async getSearchTipsList({commit},{keywordPrefix}){
		const result = await this.$API.search.getSearchTipsList(keywordPrefix)
		if (result.code ==='200'){
			commit('SET_SEARCH_TIPS_LIST',result.data)
		}
	},
	// 获取搜索到的商品展示列表
	// {keyWord,categoryId}
	async getSearchShowGoodsInfo({commit}, params){
		const result = await this.$API.search.getSearchShowGoodsInfo(params)
		if (result.code ==='200'){
			commit('SET_SEARCH_GOODS_INFO',result.data)
		}
	}
}
const getters = {}

export default {
	state,
	mutations,
	actions,
	getters
}
